<template>
  <div class="main">

    <div class="user-detail-container default-margin">

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" icon="el-icon-plus" size="mini" @click="toBlackList">黑名单</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="primary" icon="el-icon-plus" size="mini" @click="toLike">我的喜欢</el-button>
        </el-col>
      </el-row>
      <div style="margin-bottom: 50px"/>
      <van-cell title="手机号码:" :value="userInfo.phone" />
      <van-cell title="昵称:" :value="userInfo.nickname" />
      <van-cell title="用户编号:" :value="userInfo.id" />
      <van-cell title="性别:" :value="userInfo.gender == 1 ? '男' : '女'" />
      <van-cell title="邀请码:" :value="userInfo.inviteCode" />
      <van-cell title="会员:" :value="userInfo.vipLevel" />
      <van-cell title="会员截止:" :value="userInfo.vipEnd" />
      <van-cell title="城市:" :value="userInfo.city" />
      <van-cell title="自我介绍:" :value="userInfo.selfDesc" />
      <van-cell title="职业:" :value="userInfo.profession" />
      <van-cell title="年薪:" :value="userInfo.salaryYear" />
      <van-cell title="微信:" :value="userInfo.wechatAccount" />
      <van-cell title="标签:" :value="userInfo.flags" />
      <van-cell title="是否隐藏:" :value="userInfo.isHide" />

      <van-cell title="创建时间:" :value="userInfo.createTime" />
      <van-cell title="更新时间:" :value="userInfo.updateTime" />


      <div style="margin-bottom: 150px"/>


    </div>


  </div>
</template>
<script>

  import {getUser} from "../../../api/friend";
  import {SUCCESS} from "../../../comm/constant";

  export default {
    data() {
      return {
        loading: false,
        userDesc:'',
        username: null,
        userPhone: null,
        userInfo: {},
        debitCard: [],
        creditCardList:[],
        showDebitEmpty: false,
        showCreditEmpty: false,
        newPwd: null,
        comPwd: null,
        showResetPwd: false,
      }
    },
    methods: {
      toLike() {
        this.$router.push({
          path: "/friend/user/like",
          query: {
            username: this.username,
          }
        });
      },
      toBlackList() {
        this.$router.push({
          path: "/friend/user/black",
          query: {
            username: this.username,
          }
        });
      },
      formatDate(date) {
        return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
      },
      onClickLeft() {
        this.$router.go(-1);
      },
      getUserInfo() {
        //获取用户信息
        let params = {};
        if(this.username != null && this.username !== 'null'){
          params.username = this.username;
        }
        if(this.userPhone && this.userPhone != null){
          params.phone = this.userPhone;
        }
        console.info(params);
        getUser(params).then(res =>{
          if(res.code!==SUCCESS){
            this.$notify({ type: 'danger', message: res.msg });
            return;
          }
          this.userInfo = res.data;
          this.userDesc = this.userInfo.nickname;

        });

      },
    },

    mounted() {
      this.username = this.$route.query.username;
      this.userPhone = this.$route.query.phone;
      this.userDesc = this.$route.query.userDesc;
      console.info(this.$route.query);
      this.getUserInfo(this.username);
    }

  }
</script>
<style scoped>
  .user-detail-container .van-dropdown-menu{
    width: 90px;
  }
  .user-detail-container van-dropdown-menu .van-cell__value{

  }
  .save-button{
    padding: 10px 0px;
    border-bottom: 1px solid #cccccc;
  }
  .diolog-input-container{
    padding: 18px 17px;
    border-bottom: 1px solid #cccccc;
    border-top: 1px solid #cccccc;
  }
  .diolog-input-container .van-field{
    border: 0px;
    padding: 8px;
  }
  .diolog-input-container .van-divider{
    margin: 8px 0px;
  }
</style>
